<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>WinWaitClose</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>WinWaitClose</h1>

<p>Waits until the specified window
does not exist.</p>

<pre class="Syntax">WinWaitClose [, WinTitle, WinText, Seconds, ExcludeTitle, ExcludeText]</pre>
<h3>Parameters</h3>
<dl>

  <dt>WinTitle</dt>
  <dd><p>A window title or other criteria identifying the target window. See <a href="../misc/WinTitle.htm">WinTitle</a>.</p></dd>

  <dt>WinText</dt>
  <dd><p>If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if <a href="DetectHiddenText.htm">DetectHiddenText</a> is ON.</p></dd>

  <dt>Seconds</dt>
  <dd><p>How many seconds to wait before timing out and setting <a href="../misc/ErrorLevel.htm">ErrorLevel</a> to 1. Leave blank to wait indefinitely. Specifying 0 is the same as specifying 0.5. This parameter can be an <a href="../Variables.htm#Expressions">expression</a>.</p></dd>

  <dt>ExcludeTitle</dt>
  <dd><p>Windows whose titles include this value will not be considered.</p></dd>

  <dt>ExcludeText</dt>
  <dd><p>Windows whose text include this value will not be considered.</p></dd>

</dl>

<h3>ErrorLevel</h3>
<p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 if the command timed out or 0 otherwise.</p>
<h3>Remarks</h3>
<p>Whenever no  instances of the specified window exist, the command will not wait for <em>Seconds</em> to expire. Instead, it will immediately set <a href="../misc/ErrorLevel.htm">ErrorLevel</a> to 0 and the script will continue executing.</p>
<p>While the command is in a waiting state, new <a href="../misc/Threads.htm">threads</a> can be launched via <a href="../Hotkeys.htm">hotkey</a>, <a href="Menu.htm">custom menu item</a>, or <a href="SetTimer.htm">timer</a>.</p>
<p>If another <a href="../misc/Threads.htm">thread</a> changes the contents of any variable(s) that were used for this command's parameters, the command will not see the change -- it will continue to use the title and text that were originally present in the variables when the command first started waiting.</p>
<p>Window titles and text are case sensitive. Hidden windows are not detected unless <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a> has been turned on.</p>

<h3>Related</h3>
<p><a href="WinClose.htm">WinClose</a>, <a href="WinWait.htm">WinWait</a>, <a href="WinWaitActive.htm">WinWaitActive</a>, <a href="WinExist.htm">IfWinExist</a>, <a href="WinActive.htm">IfWinActive</a>, <a href="Process.htm">Process</a>, <a href="SetTitleMatchMode.htm">SetTitleMatchMode</a>, <a href="DetectHiddenWindows.htm">DetectHiddenWindows</a></p>
<h3>Example</h3>
<pre class="NoIndent">Run, notepad.exe
WinWait, Untitled - Notepad
WinWaitClose  <em>; Wait for the exact window found by WinWait to be closed.</em>
MsgBox, Notepad is now closed.</pre>

</body>
</html>
